<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/11/4
 * Time: 15:29
 */
namespace Admin\Controller;

use Common\Controller\BaseController;
use Think\Verify;

class InitController extends BaseController {

    public function _initialize() {

        parent::_initialize();
        if (C('USER_AUTH_ON')
            && !in_array(CONTROLLER_NAME, explode(',', C('NOT_AUTH_MODULE')))
            && !in_array(CONTROLLER_NAME . '/' . ACTION_NAME, explode(',', C('NOT_AUTH_ACTION')))
        ) {
            if (!session(C('USER_AUTH_KEY'))) {
                $this->redirect(C('USER_AUTH_GATEWAY'));
            }
        }
    }

    /**
     * 生成验证码
     */
    public function verify()
    {
        $Verify = new Verify();
        $Verify->length = 4;
        $Verify->codeSet = '123456789';
        $Verify->useNoise = false;
        $Verify->useImgBg = true;
        $Verify->entry();
    }
}